package net.randomice.emf.observables.demo.extlibrary.items.observables;

import net.randomice.emf.observables.demo.extlibrary.items.Item;
import net.randomice.emf.observables.demo.extlibrary.items.ItemsPackage;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;

/**
 * An Observable list wrapper for {@link Item}
 * @generated
 */
public class ItemOS {
	public final IObservableSet o;

	public ItemOS(IObservableSet observableSet) {
		Object type = observableSet.getElementType();
		if (type instanceof EReference) {
			type = ((EReference) type).getEType().getInstanceClass();
		}
		Assert.isTrue(null == type || Item.class.equals(type));
		o = observableSet;
	}

	public IObservableMap getMapFeature(EStructuralFeature feature) {
		if (ItemsPackage.Literals.ITEM__PUBLICATION_DATE.equals(feature)) {
			return getPublicationDate();
		}
		throw new UnsupportedOperationException("Feature " + feature
				+ " not supported!");
	}

	// features from type Item

	private IObservableMap publicationDate = null;
	public IObservableMap getPublicationDate() {
		if (null == publicationDate) {
			publicationDate = EMFObservables.observeMap(o,
					ItemsPackage.Literals.ITEM__PUBLICATION_DATE);
		}
		return publicationDate;
	}

}
